<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\DB;

class QueryCounterServiceProvider extends ServiceProvider
{
    /**
     * 服务提供者引导应用服务。
     *
     * @return void
     */
    public function boot()
    {
        if(false){
            DB::listen(function ($query) {
                DB::listen(function ($query) {
                    // 每次查询时增加计数
//                    global $__MINI_GLOBAL_SQL_QUERY_TIMES;
//                    $__MINI_GLOBAL_SQL_QUERY_TIMES += 1;
                    // 可选：记录查询和执行时间
                    _logger_(__file__, __line__, $query->sql . "\n---------------------------------------------\n" . json_encode($query->bindings)."\n---------------------------------------------\n" .json_encode($query->connection). "\n---------------------------------------------\n" .$query->time );
                });
            });
        }
    }
}
